import _axios from './axios';

// 城市 - 获取所有城市
function Allcity() {
    return _axios({
        url: "/city",
        method: "GET",
        headers:{
            "x-token":sessionStorage.getItem("token")
        }
    })
}

// 添加地址
function address(name,phone,area,area_name,desc) {
    return _axios({
        url: "/address",
        method: "POST",
        headers:{
            "x-token":sessionStorage.getItem("token")
        },
        data:{
            name,
            phone,
            area,
            area_name,
            desc
        }
    })
}

// 获取地址
function Getaddress() {
    return _axios({
        url: "/address",
        headers:{
            "x-token":sessionStorage.getItem("token")
        }
    })
}

// 更新地址
function Updateaddress(name,phone,area,desc,id) {
    return _axios({
        url: "/address/"+id,
        method:"PUT",
        headers:{
            "x-token":sessionStorage.getItem("token")
        },
        data:{
            name,
            phone,
            area,
            desc,
            id
        }

    })
}

// 删除
function deleteddress(id) {
    return _axios({
        url: "/address/"+id,
        method:"DELETE",
        headers:{
            "x-token":sessionStorage.getItem("token")
        },
        data:{
            id
        }
    })
}
export  {Allcity,address,Getaddress,Updateaddress,deleteddress};